/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nominalitzacions.domain;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 *
 * @author marc.mauri
 */
public class Languages {

    protected TreeMap<String, Language> languages;

    public Languages() {
        languages = new TreeMap<String, Language>();
    }

    public String[] getLanguageNames() {
        int length = languages.size();
        String[] languageNames = new String[length];
        Set<Map.Entry<String, Language> > langs = languages.entrySet();
        Iterator<Map.Entry<String, Language> > lit = langs.iterator();
        for (int i = 0; i < length; ++i) {
            Map.Entry<String, Language> lang = lit.next();
            languageNames[i] = lang.getKey();
        }
        return languageNames;
    }

    public void addLanguage(Language lang) {
        String langName = lang.getLanguageName();
        languages.put(langName, lang);
    }

    public void deleteLanguage(String langName) {
        languages.remove(langName);
    }

    Language getLanguage(String langName) {
        return languages.get(langName);
    }

}
